import { createRouter, createWebHashHistory } from "vue-router"
import Layout from "@/views/layout/index.vue"
const routes = [
    {
        path: "/",
        component: Layout,
        redirect: "/overview",
        children: [
            {
                path: "/overview",
                component: () => import("@/views/overview/index.vue")
            },
            {
                path: "/patientOverview",
                component: () => import("@/views/patient-overview/index.vue")
            },
            {
                path: "/physicalSign",
                component: () => import("@/views/physical-sign/index.vue")
            },
            {
                path: "/patientInfo",
                component: () => import("@/views/patient-info/index.vue")
            },
            {
                path: "/infusion",
                component: () => import("@/views/infusion-alarm/index.vue")
            },
            {
                path: "/report",
                component: () => import("@/views/handover-report/index.vue")
            },
            {
                path: "/schedulingDetails",
                component: () => import("@/views/scheduling-details/index.vue")
            },
            {
                path: "/medical",
                component: () => import("@/views/medical-style/index.vue")
            },
            {
                path: "/training",
                component: () => import("@/views/education-training/index.vue")
            }
        ]
    },
    {
        path: "/patientDetails",
        component: () => import("@/views/patient-details/index.vue")
    }
]


const router = createRouter({
    routes,
    history: createWebHashHistory()
})

//处理重复点击报错
router.onError(error => {
    const fetchResourcesErrors = ['Failed to fetch dynamically imported module', 'Importing a module script failed']
    if (fetchResourcesErrors.some((item) => error?.message && error.message?.includes(item))) {
        window.location.reload()
    }
})

export default router